﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Environment;
using Pixysoft.Weblications.Sango.Formular;
using Pixysoft.Weblications.Sango.Protocol.strategy;

namespace Pixysoft.Weblications.Sango.Protocol
{
    class StrategyFacade
    {
        public static List<player_strategy> ToStrategies(List<Entities.Usr_Strategy> orms)
        {
            List<player_strategy> list = new List<player_strategy>();

            foreach (Entities.Usr_Strategy orm in orms)
            {
                list.Add(ToStrategy(orm));
            }

            return list;
        }

        public static player_strategy ToStrategy(Entities.Usr_Strategy orm)
        {
            Entities.Cti_Strategy sys = CityStrategyHelper.searchStrategy(orm.Strategytypecode);

            player_strategy body = ReflectionManager.CreatePojo<player_strategy>();
            body.serialcode = orm.Strategytypecode;
            body.name = orm.Strategyname;
            body.value = orm.Strategyvalue;
            body.description = sys.Description;
            body.level = orm.Strategylevel;
            body.requiredlevel = StrategyFormular.getStrategyUpgradeBuildingLevel(sys, orm.Strategylevel);
            body.soul = StrategyFormular.getStragetyUpgradeSoulvalue(sys, orm.Strategylevel);
            body.istactical = SettingHelper.BooleanValue(sys.Istactical);
            body.typecode = sys.Strategytypecode;
            return body;
        }
    }
}
